package com.wy.service.impl.wy;

import com.wy.bean.NoticeBean;
import com.wy.constants.CommonConstants;
import com.wy.constants.CommonValues;
import com.wy.dao.NoticeEntityMapper;
import com.wy.model.sys.NoticeEntity;
import com.wy.service.wy.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service("noticeServiceImpl")
public class NoticeServiceImpl implements NoticeService {

	@Autowired
	private NoticeEntityMapper noticeEntityMapper;

	@Override
	public List<NoticeBean> noticeList(int pageSize, int start, String content, String type, String ntype, String publishTimeStart, String publishTimeEnd, String status,List<String> rids) {
//		List<NoticeBean> noticeBeans = noticeEntityMapper.noticeList(pageSize,start,content,type,ntype,publishTimeStart,publishTimeEnd,status);
//		for(NoticeBean noticeBean : noticeBeans) {
//			if (!StringUtils.isEmpty(noticeBean.getImg1())) {
//				noticeBean.setImg1(path + noticeBean.getImg1());
//			}
//			if (!StringUtils.isEmpty(noticeBean.getImg2())) {
//				noticeBean.setImg2(path + noticeBean.getImg2());
//			}
//			if (!StringUtils.isEmpty(noticeBean.getImg3())) {
//				noticeBean.setImg3(path + noticeBean.getImg3());
//			}
//		}
		return  noticeEntityMapper.noticeList(pageSize,start,content,type,ntype,publishTimeStart,publishTimeEnd,status);
	}

	@Override
	public Integer noticeSize(int pageSize, int start, String content, String type, String ntype, String publishTimeStart, String publishTimeEnd, String status,List<String> rids) {
		return noticeEntityMapper.noticeSize(pageSize,start,content,type,ntype,publishTimeStart,publishTimeEnd,status);
	}

	@Override
	public void insertNotice(NoticeEntity noticeEntity) {
		noticeEntityMapper.insert(noticeEntity);
	}

	@Override
	public void updateNotice(NoticeEntity noticeEntity) {
		noticeEntityMapper.updateByPrimaryKey(noticeEntity);
	}

	@Override
	public void deleteNotice(List<String> groupId) {
		noticeEntityMapper.deleteByPrimaryKey(groupId);
	}

	@Override
	public List<NoticeEntity> noticeList(int pageSize, int start, String type, String ntype,String readStatus, int uid) {
		return noticeEntityMapper.noticeList1(pageSize,start,type,ntype,readStatus,uid);
	}

	@Override
	public Integer noticeSize(int pageSize, int start, String type, String ntype,String readStatus, int uid) {
		return noticeEntityMapper.noticeSize1(pageSize,start,type,ntype,readStatus,uid);
	}

	@Override
	public List<NoticeEntity> getNoticeByPublishTime(String time) {
		return noticeEntityMapper.getNoticeByPublishTime(time);
	}

}
